/**
 * Copyright © 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.jeeplus.modules.xs_book_classify.entity;


import com.jeeplus.common.utils.SpringContextHolder;
import com.jeeplus.core.persistence.DataEntity;
import com.jeeplus.common.utils.excel.annotation.ExcelField;
import com.jeeplus.modules.xs_book.entity.XsBook;
import com.jeeplus.modules.xs_book.mapper.XsBookMapper;
import com.jeeplus.modules.xs_book_classify.mapper.XsBookClassifyMapper;
import lombok.Data;

import java.util.List;

/**
 * 书籍分类信息Entity
 * @author 天竹子
 * @version 2021-07-15
 */
@Data
public class XsBookClassify extends DataEntity<XsBookClassify> {
	
	private static final long serialVersionUID = 1L;
	@ExcelField(title="类型(1.看书2.听书)", dictType="type", align=2, sort=1)
	private String type;		// 类型(1.看书2.听书)
	@ExcelField(title="分类名称", align=2, sort=2)
	private String classify;		// 分类名称
	@ExcelField(title="分类图片", align=2, sort=3)
	private String img;		// 分类图片
	
	public XsBookClassify() {
		super();
		this.setIdType(IDTYPE_AUTO);
	}
	
	public XsBookClassify(String id){
		super(id);
	}

	public static XsBookClassify getValue(String name){
		XsBookClassify xsBookClassify = new XsBookClassify();
		xsBookClassify.setClassify(name);
		List<XsBookClassify> list = SpringContextHolder.getBean(XsBookClassifyMapper.class).findList(xsBookClassify);
		if(list.size()>0){
			return list.get(0);
		}else{
			return new XsBookClassify ();
		}
	}
}